source(here::here("code/load.R"))

cols <- colnames(read_excel(here("data/meta_analyses_raw/TriWen2020/Review Dataset Trinn & Wencker.xlsx")))

here("data/meta_analyses_raw/TriWen2020/Review Dataset Trinn & Wencker.xlsx") |>
  read_excel(skip = 1) |>
  setNames(cols) |>
  mutate(meta_id = "TriWen2020",
         subfield = "IR",
         question = "Causes of violent instrastate conflict",
         overall_effect = "no",
         study_id = paste(Authors, Year),
         #This will drop non-numeric values, which we need to do
         Stand_error = as.numeric(Stand_error)) |>
  #basic data cleaning
  filter(IV4 != "NA") |>
  #create t-stats and make sure that all significant results have t > 1.96
  #the motivation here is lots of their Stand_error values look like p-values or
  #t-stats, and I want to catch and remove those
  mutate(Significant_test = as.numeric(abs(Coefficient / Stand_error) > 1.96)) |>
  #drop any rows where Significant_test != Significant (which they coded)
  filter(Significant_test == Significant) |>
  select(meta_id,
         subfield,
         question,
         study_id = study_id,
         study_year = Year,
         study_journal = Journal,
         estimate = Coefficient,
         dv = DV3,
         iv = IV4,
         std.error = Stand_error,
         overall_effect) |>
  write_csv(here("data/meta_analyses_clean/TriWen2020.csv"))



